<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">
<meta name="referrer" content="same-origin">
<meta name="referrer" content="no-referrer" />








<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Netty之旅," />










<meta name="description" content="内存分配器ByteBufAllocator&amp;emsp;&amp;emsp;ByteBufAllocator是ByteBuf的内存分配器，下面是其实现：UnpooledByteBufAllocator不说了，这里主要是探讨一下PooledByteBufAllocator。PooledByteBufAllocator是池化空间的内存分配器，其内部实际依赖于PoolArena来分配内存。PoolArena是我们">
<meta name="keywords" content="Netty之旅">
<meta property="og:type" content="article">
<meta property="og:title" content="Netty之旅（三）ByteBuf内存三剑客以及算法概要">
<meta property="og:url" content="http://yoursite.com/2018/07/28/Netty之旅（三）ByteBuf内存管理/index.html">
<meta property="og:site_name" content="矩阵编程">
<meta property="og:description" content="内存分配器ByteBufAllocator&amp;emsp;&amp;emsp;ByteBufAllocator是ByteBuf的内存分配器，下面是其实现：UnpooledByteBufAllocator不说了，这里主要是探讨一下PooledByteBufAllocator。PooledByteBufAllocator是池化空间的内存分配器，其内部实际依赖于PoolArena来分配内存。PoolArena是我们">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://ww1.sinaimg.cn/large/639cfad5gy1fts8nj8gyvj20s80c43zi.jpg">
<meta property="og:image" content="http://ww1.sinaimg.cn/large/639cfad5gy1ftz5koynqyj20gm09m3zh.jpg">
<meta property="og:image" content="http://ww1.sinaimg.cn/large/639cfad5gy1fu0bnudmx4j20ho0c13z6.jpg">
<meta property="og:image" content="http://ww1.sinaimg.cn/large/639cfad5gy1fu0clp6lz8j20940cvdgd.jpg">
<meta property="og:updated_time" content="2019-10-24T16:22:00.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Netty之旅（三）ByteBuf内存三剑客以及算法概要">
<meta name="twitter:description" content="内存分配器ByteBufAllocator&amp;emsp;&amp;emsp;ByteBufAllocator是ByteBuf的内存分配器，下面是其实现：UnpooledByteBufAllocator不说了，这里主要是探讨一下PooledByteBufAllocator。PooledByteBufAllocator是池化空间的内存分配器，其内部实际依赖于PoolArena来分配内存。PoolArena是我们">
<meta name="twitter:image" content="http://ww1.sinaimg.cn/large/639cfad5gy1fts8nj8gyvj20s80c43zi.jpg">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2018/07/28/Netty之旅（三）ByteBuf内存管理/"/>





  <title>Netty之旅（三）ByteBuf内存三剑客以及算法概要 | 矩阵编程</title>
  





  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "https://hm.baidu.com/hm.js?7d29e6fba8e07d1a8af2414a20e5f2a6";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>




</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">矩阵编程</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-主页">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-主页"></i> <br />
            
            主页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-分类"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-所有文章">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-文章"></i> <br />
            
            所有文章
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2018/07/28/Netty之旅（三）ByteBuf内存管理/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="matrix">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="矩阵编程">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Netty之旅（三）ByteBuf内存三剑客以及算法概要</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2018-07-28T18:02:39+08:00">
                2018-07-28
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Netty之旅/" itemprop="url" rel="index">
                    <span itemprop="name">Netty之旅</span>
                  </a>
                </span>

                
                
              
            </span>
          

          
            
              <span class="post-comments-count">
                <span class="post-meta-divider">|</span>
                <span class="post-meta-item-icon">
                  <i class="fa fa-comment-o"></i>
                </span>
                <a href="/2018/07/28/Netty之旅（三）ByteBuf内存管理/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count disqus-comment-count"
                        data-disqus-identifier="2018/07/28/Netty之旅（三）ByteBuf内存管理/" itemprop="commentCount"></span>
                </a>
              </span>
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h3 id="内存分配器ByteBufAllocator"><a href="#内存分配器ByteBufAllocator" class="headerlink" title="内存分配器ByteBufAllocator"></a>内存分配器ByteBufAllocator</h3><p>&emsp;&emsp;ByteBufAllocator是ByteBuf的内存分配器，下面是其实现：<br><img src="http://ww1.sinaimg.cn/large/639cfad5gy1fts8nj8gyvj20s80c43zi.jpg" alt="Alt text"><br>UnpooledByteBufAllocator不说了，这里主要是探讨一下PooledByteBufAllocator。PooledByteBufAllocator是池化空间的内存分配器，其内部实际依赖于PoolArena来分配内存。PoolArena是我们内存管理的第一剑客，为了提高并发效率，PooledByteBufAllocator可以有多个PoolArena来分配内存，下面是默认的堆内存PoolArena数量和直接内存PoolArena数量：<br><a id="more"></a><br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">final int defaultMinNumArena = NettyRuntime.availableProcessors() * 2;</span><br><span class="line">final int defaultChunkSize = DEFAULT_PAGE_SIZE &lt;&lt; DEFAULT_MAX_ORDER;</span><br><span class="line">DEFAULT_NUM_HEAP_ARENA = Math.max(0,</span><br><span class="line">        SystemPropertyUtil.getInt(</span><br><span class="line">                &quot;io.netty.allocator.numHeapArenas&quot;,</span><br><span class="line">                (int) Math.min(</span><br><span class="line">                        defaultMinNumArena,</span><br><span class="line">                        runtime.maxMemory() / defaultChunkSize / 2 / 3)));</span><br><span class="line">DEFAULT_NUM_DIRECT_ARENA = Math.max(0,</span><br><span class="line">        SystemPropertyUtil.getInt(</span><br><span class="line">                &quot;io.netty.allocator.numDirectArenas&quot;,</span><br><span class="line">                (int) Math.min(</span><br><span class="line">                        defaultMinNumArena,</span><br><span class="line">                        PlatformDependent.maxDirectMemory() / defaultChunkSize / 2 / 3)));</span><br></pre></td></tr></table></figure></p>
<p><strong>DEFAULT_PAGE_SIZE</strong>默认为8192，<strong>DEFAULT_MAX_ORDER</strong>默认为11，这两个常量很重要，跟后面的内存管理息息相关。来看下PooledByteBufAllocator实际分配heapBuffer的地方：<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">protected ByteBuf newHeapBuffer(int initialCapacity, int maxCapacity) &#123;</span><br><span class="line">        // 优先获取线程缓存的 PoolArena，这就是上面说为什么有多个PoolArena</span><br><span class="line">        PoolThreadCache cache = threadCache.get();</span><br><span class="line">        PoolArena&lt;byte[]&gt; heapArena = cache.heapArena;</span><br><span class="line"></span><br><span class="line">        final ByteBuf buf;</span><br><span class="line">        if (heapArena != null) &#123;</span><br><span class="line">            // 使用PoolArena来获取ByteBuf</span><br><span class="line">            buf = heapArena.allocate(cache, initialCapacity, maxCapacity);</span><br><span class="line">        &#125; else &#123;</span><br><span class="line">            // 第一次进来，线程没有PoolArena缓存，直接返回一个未池化的ByteBuf</span><br><span class="line">            buf = PlatformDependent.hasUnsafe() ?</span><br><span class="line">                    new UnpooledUnsafeHeapByteBuf(this, initialCapacity, maxCapacity) :</span><br><span class="line">                    new UnpooledHeapByteBuf(this, initialCapacity, maxCapacity);</span><br><span class="line">        &#125;</span><br><span class="line"></span><br><span class="line">        return toLeakAwareBuffer(buf);</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure></p>
<p><strong>PoolArena</strong>虽然是实际的内存操纵者，但是，他自己却不干活，实质上也是一个管理者，来看下它内部的劳工<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">private final PoolSubpage&lt;T&gt;[] tinySubpagePools;</span><br><span class="line">private final PoolSubpage&lt;T&gt;[] smallSubpagePools;</span><br><span class="line">private final PoolChunkList&lt;T&gt; q050;</span><br><span class="line">private final PoolChunkList&lt;T&gt; q025;</span><br><span class="line">private final PoolChunkList&lt;T&gt; q000;</span><br><span class="line">private final PoolChunkList&lt;T&gt; qInit;</span><br><span class="line">private final PoolChunkList&lt;T&gt; q075;</span><br><span class="line">private final PoolChunkList&lt;T&gt; q100;</span><br></pre></td></tr></table></figure></p>
<p>由此，Netty的内存三剑客差不多已经浮出了水面，其中一位便是<strong>PoolSubpage</strong>，不过还有一位并不是这里的PoolChunkList，因为进入PoolChunkList我又发现了一位劳工，三剑客之一<strong>PoolChunk</strong>。因为实质上PoolChunkList的引入就是为了更高效的管理PoolChunk，他组成了劳工的工会。至此，<strong>PoolArena</strong>、<strong>PoolSubpage</strong>、<strong>PoolChunk</strong>便组成了我们的内存三剑客。</p>
<h3 id="Netty内存管理概要"><a href="#Netty内存管理概要" class="headerlink" title="Netty内存管理概要"></a>Netty内存管理概要</h3><h4 id="Buddy算法和Slab机制"><a href="#Buddy算法和Slab机制" class="headerlink" title="Buddy算法和Slab机制"></a>Buddy算法和Slab机制</h4><p>&emsp;&emsp;Buddy算法利用计算机可以快速计算2次幂的特性，将内存中的页按照2^N划分，比如把内存分为1，2，4，8，16，32，64……个连续页，每个页有一定大小。假设一个页4KB大小，为了申请1M大小的空间，可以先从256页框去查找，如果该页框空间不足2M大小，就从512的页框查找，如果该页框空闲，会被一分为二，并将其中的一块分配给用户使用。被拆分后的两个小块，就是伙伴了。下面是一个完整的示例：<br><img src="http://ww1.sinaimg.cn/large/639cfad5gy1ftz5koynqyj20gm09m3zh.jpg" alt="Alt text"><br>简单解释下，假设分配70K大小空间，因为页都是2次幂，所以实际上需要给他分配128K大小。接着分配35K大小，初始128K被分配了，256K被一分为二，剩余的128继续拆分，分成两个64K大小……如此循环往复，去寻找相匹配的页。<br>&emsp;&emsp;从上面Buddy算法来看，虽然分配连续内存空间的效率很高，但是也因为2次幂的特性，导致空间被浪费，如果用来分配小内存空间，那就更加浪费了，因为Buddy分配内存大小是以页为单位的。比如我们要分配10B大小，总不能直接给分配一页空间吧。所以，为了解决小内存分配的问题，有了Slab机制。Slab是一个对象缓存池，他就像一个零售店，从Buddy那里批发内存，对象是他的基本商品。</p>
<h4 id="jemalloc内存分配"><a href="#jemalloc内存分配" class="headerlink" title="jemalloc内存分配"></a>jemalloc内存分配</h4><p>&emsp;&emsp;Netty的内存设计很大程度上借鉴了jemalloc，比如<strong>Arena</strong>和<strong>Thread Cache</strong>。<strong>Arena</strong>是一个完全自治的区域，他将内存页划分为<strong>Chunk</strong>，多个页构成一个<strong>Chunk</strong>，比如在jemalloc中建议<strong>Chunk</strong>为4MB大小。<strong>Arena</strong>内部维护了一个bin数组，bin中有多个Run，一个Run就是Chunk内的一块区域，每个Run大于等于一个Page，根据Page Run的内存使用率，将其分为QINIT，Q0，Q25，Q50，Q75，Q100，使用率分组参照下面：<br><img src="http://ww1.sinaimg.cn/large/639cfad5gy1fu0bnudmx4j20ho0c13z6.jpg" alt="Alt text"><br>bin还管理着内存的分配方式，它根据内存大小分为三个尺寸，分别是<strong>small</strong>，<strong>large</strong>，<strong>huge</strong>，具体参照下图：<br><img src="http://ww1.sinaimg.cn/large/639cfad5gy1fu0clp6lz8j20940cvdgd.jpg" alt="Alt text"><br>&emsp;&emsp;<strong>Thread Cache</strong>保证多线程并发下更高效地分配内存，每个<strong>Thread Cache</strong>对应一个<strong>Arena</strong>（通常有多个Arena），同时其内部还维护了<strong>small</strong>的缓存，每次分配小内存的时候，都会优先检测本地缓存，更有效地消除了锁竞争的开销。</p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/Netty之旅/" rel="tag"># Netty之旅</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2018/07/28/Netty之旅（二）ByteBuf引用计数/" rel="next" title="Netty之旅（二）ByteBuf引用计数">
                <i class="fa fa-chevron-left"></i> Netty之旅（二）ByteBuf引用计数
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2018/07/30/Java基础（一）CountDownLatch源码分析/" rel="prev" title="Java并发之旅（一）CountDownLatch源码分析">
                Java并发之旅（一）CountDownLatch源码分析 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  
    <div class="comments" id="comments">
      <div id="disqus_thread">
        <noscript>
          Please enable JavaScript to view the
          <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a>
        </noscript>
      </div>
    </div>

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap">
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview-wrap">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview-wrap sidebar-panel">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">matrix</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/archives">
              
                  <span class="site-state-item-count">47</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/categories/index.html">
                  <span class="site-state-item-count">18</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-tags">
                
                  <span class="site-state-item-count">19</span>
                  <span class="site-state-item-name">标签</span>
                
              </div>
            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-3"><a class="nav-link" href="#内存分配器ByteBufAllocator"><span class="nav-number">1.</span> <span class="nav-text">内存分配器ByteBufAllocator</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#Netty内存管理概要"><span class="nav-number">2.</span> <span class="nav-text">Netty内存管理概要</span></a><ol class="nav-child"><li class="nav-item nav-level-4"><a class="nav-link" href="#Buddy算法和Slab机制"><span class="nav-number">2.1.</span> <span class="nav-text">Buddy算法和Slab机制</span></a></li><li class="nav-item nav-level-4"><a class="nav-link" href="#jemalloc内存分配"><span class="nav-number">2.2.</span> <span class="nav-text">jemalloc内存分配</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">matrix</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a> v5.1.4</div>
<div class=BbeiAn-info">
  浙ICP备 -
  <a href="http://www.beian.miit.gov.cn">18040498号</a>
  </a>
</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.4"></script>



  


  

    
      <script id="dsq-count-scr" src="https://luyun.disqus.com/count.js" async></script>
    

    
      <script type="text/javascript">
        var disqus_config = function () {
          this.page.url = 'http://yoursite.com/2018/07/28/Netty之旅（三）ByteBuf内存管理/';
          this.page.identifier = '2018/07/28/Netty之旅（三）ByteBuf内存管理/';
          this.page.title = 'Netty之旅（三）ByteBuf内存三剑客以及算法概要';
        };
        var d = document, s = d.createElement('script');
        s.src = 'https://luyun.disqus.com/embed.js';
        s.setAttribute('data-timestamp', '' + +new Date());
        (d.head || d.body).appendChild(s);
      </script>
    

  




	





  














  





  

  

  

  
  

  

  

  

</body>
</html>
